#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[100], vis[100] = {0};
	int num;
	cin >> num;
	for (int i = 0; i < num; i++)
	{
		int key;
		cin >> key;
		int temp = key%n;
		int index = temp, k = 1;
		while (vis[index] != 0&&k<n)
		{
			index = (temp + k) % n;
			k++;
		}
		if (k < n)
		{
			a[index] = key;
			vis[index] = 1;
		}
	}
	int goal;
	cin >> goal;
	int temp = goal%n;
	int index = temp, k = 1;
	while (a[index] != goal && k < n)
	{
		index = (temp + k) % n;
		k++;
	}
	if (k < n)
		cout << index<<','<<k;
	else
		cout << -1;
	return 0;
}